<%@page contentType="text/plain" pageEncoding="UTF-8" import="com.mop.dinnerbook.dao.*,java.util.*,com.mop.dinnerbook.bean.*"%>
<%
    boolean ismanage = (session.getAttribute("manager") != null);
    MemberDAO dao = new MemberDAO();
    String spid = request.getParameter("pid");
    Integer pid = null;
    if(spid != null && !spid.equals(""))
    pid = Integer.parseInt(spid);
    List proList = null;
    if(pid == null || pid.intValue() == 0){
        pid = (Integer)session.getAttribute("pid");
    }
    if(pid == null || pid.intValue() == 0){
        proList = new ArrayList();
    }else{
        List memberList = dao.getMembersByPid(pid);
        ProjectDAO pdao = new ProjectDAO();
        Project bean = pdao.getProject(pid);
        bean.setMembers(memberList);
        proList = new ArrayList();
        proList.add(bean);
        session.setAttribute("pid", pid);
    }
    Iterator iter = proList.iterator();
    FloorDAO fdao = new FloorDAO();
    List floorList = fdao.getFloorList();
    while(iter.hasNext()){
        Project bean = (Project)iter.next();
        out.write("<div><font color=red size=6>请不要修改他人的订餐记录</font><br/>"+bean.getPname()+"</div>");
        out.write("<table border=1>");
        out.write("<thead><tr><td>编号</td><td>岗位</td><td>姓名</td><td>订餐</td><td>操作IP</td><td>楼层</td>");
        if(ismanage){
            out.write("<td>操作</td>");
        }
        out.write("</tr></thead>");
        Collections.sort(bean.getMembers());
        Iterator _iter = bean.getMembers().iterator();
        while(_iter.hasNext()){
            Member _bean = (Member)_iter.next();
            out.write("<tbody><tr>");
            out.write("<td>"+_bean.getMid()+"</td>");
            out.write("<td>"+_bean.getDepartment().getDname()+"</td>");
            out.write("<td>"+_bean.getMname()+"</td>");
            if(_bean.isChecked() > 0){
            	out.write("<td>"+"<input type=\"checkbox\" checked onclick=\"bookDinner(this,"+_bean.getMid()+")\"/><span id=\"mid"+_bean.getMid()+"\">&nbsp;订购成功</span></td>");
            }else{
            	out.write("<td>"+"<input type=\"checkbox\" onclick=\"bookDinner(this,"+_bean.getMid()+")\"/><span id=\"mid"+_bean.getMid()+"\">&nbsp;欢迎订餐</span></td>");
            }
            if(_bean.getActionIp() != null)
            out.write("<td><a onmouseout='hideOperator()' href='javascript:void(0)' onclick=\"showOperator('"+ _bean.getActionIp() +"')\">"+ _bean.getActionIp() +"</a></td>");
            else
            out.write("<td></td>");
            //---楼层楼层
            out.write("<td>");
            out.write("<select onchange=\"changeFloor(this,"+ _bean.getMid() +")\">");
            if(floorList != null){
                Iterator _fiter = floorList.iterator();
                while(_fiter.hasNext()){
                    Floor floor = (Floor)_fiter.next();
                    if(_bean.getFloor().getFid() != floor.getFid()){
                        out.write("<option value="+ floor.getFid() +">"+ floor.getFname() +"</option>");
                    }else{
                        out.write("<option selected value="+ floor.getFid() +">"+ floor.getFname() +"</option>");
                    }
                }
            }
            out.write("</select</td>");
            if(ismanage){
                out.write("<td><div class=\"manageButton\" onclick=\"deleteMember("+ _bean.getMid() +")\"/>删除</td>");
            }
            out.write("</tr></tbody>");
        }
        out.write("</table><br/>");
    }
%>
